package com.example.experiment_three;

import androidx.appcompat.app.AppCompatActivity;

import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

public class ConfigurationTest extends AppCompatActivity {

     TextView tv_ori;
     TextView tv_nav;
     TextView tv_touch;
     TextView tv_mnc;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_configuration_test);

        tv_ori = findViewById(R.id.ori);
        tv_nav = findViewById(R.id.nav);
        tv_touch = findViewById(R.id.touch);
        tv_mnc = findViewById(R.id.mnc);

        //Button btn = findViewById(R.id.button7);
        //btn.setOnClickListener(view -> {
            Configuration cfg = getResources().getConfiguration();
            String screen = cfg.orientation == Configuration.ORIENTATION_LANDSCAPE ?
                    "横向屏幕" : "竖向屏幕";
            String mncCode = cfg.mnc + "";
            String navName = cfg.orientation == Configuration.NAVIGATION_NONAV ?
                    "没有方向控制" :
                    (cfg.orientation == Configuration.NAVIGATION_WHEEL) ?
                            "滚轮控制方向" :
                            (cfg.orientation == Configuration.NAVIGATION_DPAD) ?
                                    "方向键控制方向" :
                                    "轨迹球控制方向";
            tv_nav.setText(navName);

            String touchName = cfg.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH ?
                    "无触摸屏" :
                    cfg.touchscreen == Configuration.TOUCHSCREEN_STYLUS ?
                            "触摸笔试触摸屏" :
                            "接受手指的触摸屏";
            tv_ori.setText(screen);
            tv_mnc.setText(mncCode);
            tv_touch.setText(touchName);

        //});
    }
}